<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <template>
              <div style="width:100%;">
                  <div style="float:left;width:50%">
                      <table style="font-size:12px" class="table1style">
                          <tr>
                              <td>快速查询</td>
                              <td>
                                  <el-input v-model="txtsearch" placeholder="病区代码或病区名称或拼音码" style="width:210px" clearable></el-input>
                              </td>
                              <td v-show="isRegLis">医院</td>
                              <td v-show="isRegLis">
                                  <rm-ddl-common @change="hospitalChange" datatype="hospital" dataname="医院" v-model="ddlhospcode" width="180px"></rm-ddl-common>
                              </td>
                          </tr>
                      </table>
                  </div>
                  <div style="float:left;width:50%;">
                      <table style="float:right">
                          <tr>
                              <td>
                                  <el-button icon="el-icon-search" @click="RefreshList" v-has="'PINQUERY'" type="primary">查询</el-button>
                              </td>
                              <td>
                                  <el-button @click="add" icon="el-icon-plus" v-has="'PADD'">新增</el-button>
                              </td>
                              <td>
                                  <el-button @click="del" icon="el-icon-delete" v-has="'PDELETE'">删除</el-button>
                              </td>
                              <td>
                                  <el-button @click="save" icon="el-icon-document">保存</el-button>
                              </td>
                              <td>
                                  <el-button @click="recordexport" icon="el-icon-upload2" v-has="'PEXPORT'">导出</el-button>
                              </td>
                              <td>
                                  <el-button @click="syncdata" icon="el-icon-position" v-has="'PSYNC'">同步</el-button>
                              </td>
                              <td>
                                  <el-button @click="dangervalperson" icon="el-icon-close-notification">危急值人员</el-button>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </template>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <vxe-table show-overflow ref="xTable1" class="mytable-style" height="auto" :loading="loading" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :mouse-config="{selected: true}" :data.sync="list" border size="mini" show-header-overflow @edit-closed="EditClose" @cell-dblclick="celldblclick" highlight-current-row highlight-hover-row resizable :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false,activeMethod:cellactiveMethod}" :cell-class-name="cellClassName" :row-class-name="rowClassName" @current-change="currentChangeEvent" :edit-rules="ward_validRules">
                  <vxe-table-column type="index" title="NO." width="50" header-align="center" align="center"></vxe-table-column>
                  <vxe-table-column field="wardno" title="病区代码" width="79" sortable header-align="center" :edit-render="{name:'input', autoselect: true}">
                      <template v-slot:header="{ column }">
                          <span style="color: blue;">病区代码</span>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="wardname" title="病区名称" width="130" header-align="center" :edit-render="{name:'input', autoselect: true}">
                      <template v-slot:header="{ column }">
                          <span style="color: blue;">病区名称</span>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="wardenname" title="英文名称" width="120" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                  <vxe-table-column field="his_wardno" title="病区代码(HIS)" width="90" header-align="center" :edit-render="{name:'input', autoselect: true}">
                      <template v-slot:header="{ column }">
                          <span style="color: blue;">病区代码(HIS)</span>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="telnum" title="联系电话" width="100" sortable header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                  <vxe-table-column field="dangercnt" title="危急值通知人数" width="100" header-align="center" align="center"></vxe-table-column>
                  <vxe-table-column field="description" title="备注说明" width="200" header-align="center" :edit-render="{name:'input', autoselect: true}">
                  </vxe-table-column>
                  <vxe-table-column field="inputcode" title="输入码" width="100" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                  <vxe-table-column field="invalidflag" title="停用" width="60" header-align="center" align="center">
                      <template v-slot="{row}">
                          <el-checkbox v-model="row.invalidflag" true-label="1" false-label="0"></el-checkbox>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="hospcode" title="医院" width="220" header-align="center" :edit-render="{name:'select', options: HospitalOptions}">
                  </vxe-table-column>
                  <vxe-table-column field="bedsnum" title="床位数" width="80" header-align="center" :edit-render="{name:'input', autoselect: true}" align="center"></vxe-table-column>
              </vxe-table>
          </div>
      </div>
      <el-dialog title="提示" :visible.sync="dialogDelVisible" width="30%">
          <span class="el-icon-info">确定删除科室名称为<b style="color:red">{{message}}</b>的记录吗？</span>
          <span slot="footer" class="dialog-footer">
              <el-button @click="confirmdel">确 定</el-button>
              <el-button @click="dialogDelVisible=false" :autofocus="true">取 消</el-button>
          </span>
      </el-dialog>
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="请选择病区对应危急值通知人员" :visible.sync="dialogDangervalVisible" width="1075px">
          <template>
              <div style="height:500px;width:100%;position:relative;">
                  <div class="poppagetop">
                      <div style="float:left;width:50%;text-align:center;margin-top:5px">
                          <table class="table1style">
                              <tr>
                                  <td>快速查询</td>
                                  <td>
                                      <el-input v-model="txtquicksearch" style="width:400px" placeholder="医生代码或医生名称或输入码" @keyup.enter.native="doctorquery"></el-input>
                                  </td>
                              </tr>
                          </table>
                      </div>
                      <div style="float:left;width:50%;text-align:center;margin-top:5px">
                          <el-button @click="dialogDangervalVisibleSave">保 存</el-button>
                          <el-button @click="dialogDangervalVisible = false">取 消</el-button>
                      </div>
                  </div>
                  <div class="poppagecenter">
                      <div class="popmiddle-left">
                          <vxe-table show-overflow ref="xTable2" height="auto" :loading="loading" @cell-dblclick="selectchange" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" @keyup.enter.native="popenterselect" fit :data.sync="tableData2" show-header-overflow highlight-current-row highlight-hover-row resizable border size="mini" @current-change="popcurrentChangeEvent">
                              <vxe-table-column type="index" title="NO." width="60"></vxe-table-column>
                              <vxe-table-column field="doctorno" title="医生代码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="doctorname" title="医生姓名" width="100" header-align="center"></vxe-table-column>
                              <vxe-table-column field="doctorkind" title="医生类别" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="inputcode" title="输入码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="shortmsgcode" title="短信接收号码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="his_doctorno" title="HIS代码" width="100" header-align="center">
                              </vxe-table-column>
                          </vxe-table>
                      </div>
                      <div class="popmiddle-center">
                          <div style="margin-top:150px">
                              <table>
                                  <tr>
                                      <td>
                                          <el-button type="button" style="width:60px;height:30px;" @click.native="popinsertdata"><span><i class="el-icon-right"></i></span></el-button>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>
                                          <el-button type="button" style="width:60px;height:30px;" @click.native="popdeletedata"><span><i class="el-icon-back"></i></span></el-button>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </div>
                      <div class="popmiddle-right">
                          <vxe-table show-overflow ref="xTable3" height="auto" :loading="loading" @cell-dblclick="delselectchange" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" fit :data.sync="tableData3" show-header-overflow highlight-current-row highlight-hover-row resizable border size="mini" @current-change="popcurrentChangeEvent2">
                              <vxe-table-column type="index" title="NO." width="60"></vxe-table-column>
                              <vxe-table-column field="userno" title="医生代码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="doctorname" title="医生姓名" width="100" header-align="center"></vxe-table-column>
                              <vxe-table-column field="shortmsgcode" title="短信接收号码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="deptwardno" title="病区代码" width="100" header-align="center">
                              </vxe-table-column>
                              <vxe-table-column field="vstype" title="对照类别" width="80" header-align="center">
                              </vxe-table-column>
                          </vxe-table>
                      </div>
                  </div>
              </div>
          </template>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
export default {
  name: "MNG211",
  data() {
      return {
          txtsearch: "",
          loading: false,
          okFirstLoading: true,
          isFirstLoading: false,
          dialogDelVisible: false,
          dialogdeptVisible: false,
          dialogDangervalVisible: false,
          tempindex: 0,
          actionindex: "Q",
          tempData: [],
          selectrow: [],
          popselectrow: [],
          popdelselectrow: [],
          HospitalOptions: [],
          message: "",
          txtquicksearch: "",
          ddlhospcode: "",
          wardno: "",
          isRegLis: false,
          utype: this.$tool.getSession(this.$tool.loginutype),
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
              isArrow: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          selectConfig: {
              tigger: "row",
          },
          tableData1: [],
          tableData2: [],
          tableData3: [],
          ward_validRules: {
              wardno: [{ required: true, message: "病区代码必须填写" }],
              wardname: [{ required: true, message: "病区名称必须填写" }],
              his_wardno: [{ required: true, message: "病区代码(HIS)必须填写" }],
          },
      };
  },
  created() {
      this.ddlInitdata(); //初始化下拉框的数据
      this.initialList(); //初始化主列表
      this.$ddldata.IsAreaModeFun().then((r) => {
          this.isRegLis = r;
      }); //防止刷新页面导致IsAreaMode被清掉
  },
  watch: {
      txtsearch(val, oldval) {
          if (val != oldval) {
              this.$nextTick(() => {
                  var row = this.$refs.xTable1.getCurrentRow();
                  if (this.$refs.xTable1.tableData.length > 0) row = this.$refs.xTable1.tableData[0];
                  if (row.wardno) {
                      this.$refs.xTable1.setCurrentRow(row);
                      this.tempindex = this.$refs.xTable1.getRowIndex(row);
                      this.message = row.wardname;
                  } else {
                      this.message = "";
                  }
              });
          }
      },
  },
  computed: {
      list() {
          let querystr = this.txtsearch.trim();
          if (querystr) {
              let rest = this.tableData1.filter((item) => item.wardno.indexOf(querystr) > -1 || item.wardname.indexOf(querystr) > -1 || (item.inputcode ? item.inputcode.toUpperCase().indexOf(querystr.toUpperCase()) > -1 : false));
              return rest;
          } else {
              return this.tableData1;
          }
      },
  },
  mounted() {},
  updated() {
      if (this.okFirstLoading) {
          this.FunCallUpdateRow();
      }
      if (this.isFirstLoading) {
          let xtable2row = this.$refs.xTable2.getData(0);
          let xtable3row = this.$refs.xTable3.getData(0);
          if (xtable2row) {
              this.isFirstLoading = false;
              this.$refs.xTable2.setCurrentRow(xtable2row);
              this.popselectrow = xtable2row;
          }
          if (xtable3row) {
              this.isFirstLoading = false;
              this.$refs.xTable3.setCurrentRow(xtable3row);
              this.popdelselectrow = xtable3row;
          }
      }
  },
  methods: {
      RefreshList() {
          this.actionindex = "Q";
          this.initialList();
      },
      FunCallUpdateRow() {
          let currentrow = "";
          if (this.actionindex != "D") {
              if (this.actionindex == "A") {
                  if (this.selectrow != "") {
                      console.log(this.selectrow);
                      this.$nextTick(() => {
                          var alld = this.$refs.xTable1.getTableData().fullData;
                          for (var i = 0; i < alld.length; i++) {
                              if (alld[i].wardno == this.selectrow.wardno) {
                                  this.tempindex = i;
                                  break;
                              }
                          }
                          currentrow = this.$refs.xTable1.getTableData().fullData[this.tempindex];
                      });
                  } else {
                      currentrow = this.$refs.xTable1.getTableData().fullData[0];
                  }
              } else if (this.actionindex == "M") {
                  this.$nextTick(() => {
                      var alld = this.$refs.xTable1.getTableData().fullData;
                      for (var i = 0; i < alld.length; i++) {
                          if (alld[i].wardno == this.selectrow.wardno) {
                              this.tempindex = i;
                              break;
                          }
                      }
                      currentrow = this.$refs.xTable1.getTableData().fullData[this.tempindex];
                  });
              } else {
                  currentrow = this.$refs.xTable1.getTableData().fullData[0];
              }
          } else {
              if (this.tempindex > 0) {
                  currentrow = this.$refs.xTable1.getTableData().fullData[this.tempindex];
              } else {
                  currentrow = this.$refs.xTable1.getTableData().fullData[0];
              }
          }
          //let currentrow = this.$refs.xTable1.getData(this.tempindex);
          this.$nextTick(() => {
              this.currRow = currentrow;
              if (currentrow) {
                  this.okFirstLoading = false;
                  this.$refs.xTable1.setCurrentRow(currentrow);
                  this.message = currentrow.wardname;
                  //this.selectrow = currentrow;
                  this.wardno = currentrow.wardno;
              }
          });
      },
      EditClose({ row, column, rowIndex }) {
          //写法错误，且代码无意义
          // if (column.property == "inputcode") {
          //     this.$refs.xTable1.$refs.tableBody.$children[rowIndex * 2].$el.focus();
          // } else
          if (column.property == "wardname") {
              let thisinputcode = "";
              let getpinyin = this.$pinyin(row.wardname, {
                  style: this.$pinyin.STYLE_FIRST_LETTER, // 首字母
                  heteronym: true,
              });
              for (var i = 0; i < getpinyin.length; i++) {
                  var curchar = getpinyin[i];
                  if (curchar.length > 1) {
                      thisinputcode += curchar[0];
                  } else {
                      thisinputcode += curchar;
                  }
              }
              row.inputcode = thisinputcode.toUpperCase();
          } else if (column.property == "wardno") {
              if (row.wardno != "") {
                  row.his_wardno = row.wardno;
              }
          }
      },
      ddlInitdata() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG211",
                  method: "post",
                  data: {
                      action: "ddlInitialList",
                  },
              })
              .then((response) => {
                  console.log("res", response);
                  this.HospitalOptions = response;
              });
      },
      rowClassName({ row, rowIndex }) {
          if (row.hospcode == "All" && this.utype != "G") {
              return "row-gray";
          }
          let isDirty = this.$refs.xTable1.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          } else {
              if (row.invalidflag == "1") {
                  return "rm-alert";
              }
          }
          if (this.$refs.xTable1.hasRowInsert(row)) return "row-new";
      },
      cellClassName({ columnIndex, column }) {
          if (columnIndex == "0" || column.property == "dangercnt") {
              return "col-gray";
          } else {
              return "";
          }
      },
      initialList() {
          this.loading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG211",
                  method: "post",
                  data: {
                      action: "query",
                      ddlhospcode: this.ddlhospcode,
                  },
              })
              .then((response) => {
                  this.tableData1 = response.Data;
                  //去除停用刷新到底部
                  // this.tableData1.sort((a, b) => {
                  //     return a.invalidflag - b.invalidflag;
                  // });
                  this.loading = false;
                  this.okFirstLoading = true;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.loading = false;
              });
      },
      currentChangeEvent({ row, $rowIndex }) {
          this.message = row.wardname;
          this.selectrow = row;
          this.wardno = row.wardno;
          this.tempindex = $rowIndex;
          this.actionindex = "M";
      },
      recordexport() {
          this.$refs.xTable1.exportCsv();
      },
      FunscrollY() {
          this.$nextTick(() => {
              var alldataLen = this.$refs.xTable1.tableData.length;
              let L = this.$refs.xTable1.tableData[alldataLen - 1];
              this.$refs.xTable1.setCurrentRow(L);
              this.$refs.xTable1.setActiveRow(L, "wardno");
              this.$refs.xTable1.scrollToRow(L);
          });
      },
      add() {
          let initialdata = {
              wardno: "",
              wardname: "",
              telnum: "",
              his_wardno: "",
              dangercnt: "",
              description: "",
              inputcode: "",
              invalidflag: "",
              hospcode: this.$ddldata.IsAreaMode ? this.$tool.getSession(this.$tool.selectedhis) : "All",
              bedsnum: "",
          };
          this.$refs.xTable1.insert(initialdata);
          this.FunscrollY();
          this.actionindex = "A";
          this.message = "";
      },
      del() {
          if (this.utype != "G" && this.selectrow.hospcode == "All") {
              this.$alert("您不是管理员，不能删除医院代码为All的数据！", "提示", {
                  confirmButtonText: "确定",
              });
              return false;
          } else {
              if (this.message == "") {
                  this.confirmdel();
              } else {
                  this.dialogDelVisible = true;
              }
          }
      },
      confirmdel() {
          this.dialogDelVisible = false;
          try {
              var delrow = this.$refs.xTable1.getCurrentRow();
              if (delrow) {
                  var alld = this.$refs.xTable1.tableData;
                  var rowindex = alld.indexOf(delrow);
                  this.$refs.xTable1.remove(delrow);
                  this.actionindex = "D";
                  let havedata = this.$refs.xTable1.tableData;
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.$refs.xTable1.setCurrentRow(selectrow);
                      this.message = selectrow.wardname;
                  } else {
                      this.message = "";
                  }
              }
          } catch (e) {
              alert(e);
          }
      },
      save() {
          let insertresult = [];
          let xTable1date = this.$refs.xTable1.getRecordset(); //主表数据
          let insertobj = xTable1date.insertRecords;
          for (var i = 0; i < insertobj.length; i++) {
              var obj = insertobj[i];
              if (!!obj["wardno"] && !!obj["wardname"] && !!obj["his_wardno"]) {
                  //三个必填值都有值
                  insertresult.push(obj);
              } else {
                  if (!!obj["wardno"] || !!obj["wardname"] || !!obj["his_wardno"]) {
                      //三个必填值其中一个有值
                      let msg = "病区代码(HIS)";
                      if (!obj["wardno"]) {
                          msg = "病区代码";
                      } else if (!obj["wardname"]) {
                          msg = "病区名称";
                      }
                      this.$message.warning(msg + "不能为空");
                  } else if (!obj["wardno"] && !obj["deptname"]) {
                      this.$refs.xTable1.remove(obj);
                  }
                  break;
              }
          }
          xTable1date.insertRecords = insertresult;
          this.$refs.xTable1.validate((valid) => {
              if (valid) {
                  if (this.actionindex == "A") {
                      if (xTable1date.insertRecords.length > 0) {
                          this.selectrow = xTable1date.insertRecords[0];
                      }
                  } else if (this.actionindex == "M") {
                      if (xTable1date.updateRecords.length > 0) {
                          this.selectrow = xTable1date.updateRecords[0];
                      }
                  }
                  this.$tool
                      .request({
                          url: "MNG/MNG2/MNG211",
                          method: "post",
                          data: {
                              action: "save",
                              urec: xTable1date,
                          },
                      })
                      .then((response) => {
                          if (response.errcode == "1") {
                              this.$message({
                                  message: "操作成功！",
                                  type: "success",
                              });
                              this.initialList();
                          } else {
                              this.$message({
                                  message: "保存失败！" + response.errmsg,
                                  type: "warning",
                              });
                          }
                      })
                      .catch((e) => {
                          console.log("error", e);
                      });
              }
          });
      },
      cellactiveMethod({ row, column }) {
          if (this.utype == "G") {
              return true;
          } else {
              if (this.$ddldata.IsAreaMode) {
                  if (row.hospcode == "All") {
                      return false;
                  } else {
                      return true;
                  }
              } else {
                  return true;
              }
          }
      },
      syncdata() {
          this.loading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG211",
                  method: "post",
                  data: {
                      action: "syncdata",
                  },
              })
              .then((response) => {
                  if (response.err == 0) {
                      let msg = response.msg;
                      if (!msg) msg = "同步数据获取失败！";
                      this.loading = false;
                      this.$alert(msg);
                      return;
                  }
                  let data = response.data;
                  data.forEach((item) => {
                      let rest = this.tableData1.filter((element) => element.wardno.toUpperCase() == item.wardno.toUpperCase());
                      if (rest.length > 0) {
                          try {
                              rest.forEach((ele) => {
                                  if (ele.wardno.toUpperCase() == item.wardno.toUpperCase()) {
                                      ele.wardname = item.wardname;
                                      ele.wardenname = item.wardenname == "" ? ele.wardenname : item.wardenname;
                                      ele.his_wardno = item.his_wardno == "" ? ele.wardno : item.his_wardno;
                                      ele.telnum = item.telnum == "" ? ele.telnum : item.telnum;
                                      ele.hospcode = item.hospcode == "" ? ele.hospcode : item.hospcode;
                                      ele.bedsnum = item.bedsnum == "" ? ele.bedsnum : item.bedsnum;
                                      //ele.description = ele.wardname == item.wardname ? null : item.wardname;
                                      ele.inputcode = item.inputcode;
                                      throw Error();
                                  }
                              });
                          } catch (e) {}
                      } else {
                          let initialdata = {
                              wardno: item.wardno,
                              wardname: item.wardname,
                              wardenname: item.wardenname,
                              his_wardno: item.his_wardno,
                              hospcode: item.hospcode == null ? "All" : item.hospcode,
                              telnum: item.telnum,
                              bedsnum: item.bedsnum,
                              invalidflag: item.invalidflag,
                              inputcode: item.inputcode,
                          };
                          this.$refs.xTable1.insert(initialdata);
                      }
                  });
                  this.loading = false;
                  this.$message({
                      type: "warining",
                      message: "病区字典数据更新完成！",
                  });
              })
              .catch((e) => {
                  console.log("error", e);
                  this.loading = false;
              });
      },
      celldblclick({ column }) {
          if (column.property == "dangercnt") {
              this.dangervalperson();
          }
      },
      dangervalperson() {
          this.doctorquery();
          this.dialogDangervalVisible = true;
      },
      doctorquery() {
          this.docloading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG211",
                  method: "post",
                  data: {
                      action: "doctorquery",
                      qcode: this.txtquicksearch,
                      wardno: this.wardno,
                  },
              })
              .then((response) => {
                  this.tableData2 = response.RData.Data;
                  this.tableData3 = response.RData2.Data;
                  this.docloading = false;
                  this.isFirstLoading = true;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.docloading = false;
              });
      },
      selectchange({ row }) {
          //双击选中
          // this.popselectrow=row;
          this.popinsertdata();
      },
      delselectchange() {
          //双击从右边删除
          this.popdeletedata();
      },
      popenterselect() {
          //回车选中
          this.popinsertdata();
      },
      popinsertdata() {
          let alldata = this.$refs.xTable3.tableData;
          let flag = false;
          if (alldata.length > 0) {
              alldata.forEach((item) => {
                  if (item.userno == this.popselectrow.doctorno) {
                      flag = true;
                  }
              });
          }
          if (flag == false) {
              let initialdata = {
                  userno: this.popselectrow.doctorno,
                  doctorname: this.popselectrow.doctorname,
                  shortmsgcode: this.popselectrow.shortmsgcode,
                  deptwardno: this.wardno,
                  vstype: "2",
              };
              this.$refs.xTable3.insert(initialdata);
          }
      },
      popdeletedata() {
          var delrow = this.$refs.xTable3.getCurrentRow();
          if (delrow) {
              this.$refs.xTable3.remove(delrow);
              let havedata = this.$refs.xTable3.getTableData().fullData;
              if (havedata.length > 0) {
                  let selectrow = this.$refs.xTable3.getTableData().fullData[havedata.length - 1];
                  this.$refs.xTable3.setCurrentRow(selectrow);
              }
          } else {
              this.$message({
                  message: "请先选中要删除的明细！",
                  type: "warning",
              });
          }
      },
      AlertParentdeptno() {
          this.dialogdeptVisible = true;
      },
      popcurrentChangeEvent({ row }) {
          this.popselectrow = row;
      },
      popcurrentChangeEvent2({ row }) {
          this.popdelselectrow = row;
      },
      dialogDangervalVisibleSave() {
          let xTable3date = this.$refs.xTable3.getRecordset(); //弹窗保存
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG211",
                  method: "post",
                  data: {
                      action: "dangervalpopsave",
                      urec: xTable3date,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message({
                          message: "操作成功！",
                          type: "success",
                      });
                      this.initialList();
                      this.dialogDangervalVisible = false;
                  } else {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      hospitalChange(code, name) {
          this.ddlhospcode = code;
          this.initialList();
      },
  },
};
</Script>

<style scoped>
.pagetop {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 40px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}
.poppagetop {
  width: 100%;
  height: 40px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  position: absolute;
  border: 1px solid #ccc;
  z-index: 999;
}
.poppagecenter {
  position: absolute;
  top: 50px;
  width: 100%;
  left: 0;
}
.popmiddle-left {
  background-color: aqua;
  position: absolute;
  height: 450px;
  width: 480px;
  left: 0px;
  overflow: auto;
}
.popmiddle-center {
  position: absolute;
  -webkit-box-align: center;
  height: 100%;
  left: 485px;
  right: 485px;
}
.popmiddle-right {
  position: absolute;
  top: 0;
  bottom: 0;
  height: 450px;
  width: 480px;
  right: 0px;
}
.table1style tr td {
  padding: 0px 2px 0px 5px;
}
/deep/.middle-center tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}
/deep/ .mytable-style.vxe-table .vxe-body--column.col-gray {
  background-color: #f8f8f8;
}
/deep/ .mytable-style.vxe-table .vxe-body--row.row-gray {
  background-color: #f8f8f8;
}
/deep/ tr.vxe-body--row.row-modify {
  color: blue !important;
}
/deep/ tr.vxe-body--row.row-new {
  color: red !important;
}
</style>